var t = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../@babel/runtime/regenerator")), a = require("../../../../@babel/runtime/helpers/asyncToGenerator"), e = getApp();

Page({
    data: {
        cash: "",
        radio: "1",
        checkList: [],
        pay_type: ""
    },
    onLoad: function(t) {
        this.getData();
        try {
            var a = wx.getStorageSync("mailLanguage"), e = wx.getStorageSync("yz_basic_info");
            if (a) {
                var n = JSON.parse(a);
                this.setData({
                    name_of_withdrawal: n.income && n.income.name_of_withdrawal ? n.income.name_of_withdrawal : "提现",
                    balance_name: e.balance ? e.balance : "余额"
                });
            }
        } catch (t) {}
    },
    SelectHandle: function(t) {
        this.setData({
            pay_type: t.detail,
            show1: !1
        });
    },
    allSelectHandle: function(e) {
        var n = this;
        return a(t.default.mark(function a() {
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.t0 = n, t.t1 = e.detail, t.next = 4, n.countTotalPrice(e.detail);

                  case 4:
                    t.t2 = t.sent, t.t3 = {
                        checkList: t.t1,
                        countTotal: t.t2
                    }, t.t0.setData.call(t.t0, t.t3);

                  case 7:
                  case "end":
                    return t.stop();
                }
            }, a);
        }))();
    },
    countTotalPrice: function(t) {
        var a = this, e = [];
        t.forEach(function(t, n) {
            e[n] = a.data.datasource[t];
        });
        var n = 0;
        return e.forEach(function(t) {
            n += Number(t.money);
        }), n.toFixed(2);
    },
    getWithdrawType: function() {
        this.setData({
            show1: !0
        });
    },
    show1Tap: function() {
        this.setData({
            show1: !1
        });
    },
    userValinp: function(t) {
        console.log(t.detail);
        var a = t.detail;
        this.setData({
            radio: a
        });
    },
    iscash: function(t) {
        this.setData({
            cash: t.detail.value
        });
    },
    sureCash: function() {
        var t = this, a = this, n = [];
        if (this.data.checkList.forEach(function(a, e) {
            n.push(t.data.datasource[a].id);
        }), 0 != this.data.checkList.length) if (this.data.pay_type) {
            var i = {
                ids: n,
                withdraw_type: "wechat" == this.data.pay_type ? 1 : 2 == this.data.pay_type ? 2 : 7
            }, o = e.getNetAddresss("plugin.auction.api.prepayment.withdraw.withdraw");
            e._postNetWork({
                url: o,
                data: i,
                success: function(t) {
                    var e = t.data;
                    1 == e.result && wx.showToast({
                        title: e.msg,
                        duration: 1e3,
                        icon: "none",
                        success: function() {
                            a.data.checkList.forEach(function(t) {
                                a.data.checkList.splice(t, 1);
                            }), a.setData({
                                countTotal: a.countTotalPrice(a.data.checkList)
                            }), a.getData();
                        }
                    });
                },
                fail: function(t) {
                    console.log(t), wx.showToast({
                        title: t.msg,
                        icon: "none",
                        duration: 1e3
                    });
                }
            });
        } else e.tips("请选择提现方式"); else e.tips("请选择需要提现的保证金");
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var t = this, a = e.getNetAddresss("plugin.auction.api.prepayment.withdraw.can-withdraw");
        e._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (console.log(e), t.setData({
                    Data: e.data,
                    datasource: e.data.list
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t), wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    }
});